import { createServer } from './createServer.js'
import { availableParallelism } from 'node:os';
import cluster from 'node:cluster';

const numCPUs = availableParallelism();
const port = process.env.PORT || '8080'

if (cluster.isPrimary) {
  console.log('Server listening on port %s, Ctrl+C to quit', port)
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork()
  }
} else {
  const server = createServer()
  server.listen(port)
}
